import { Injectable } from '@angular/core';
import * as d3 from 'd3';
import { StoryinfoComponent } from 'src/app/info/storyinfo/storyinfo.component';
import { node } from 'src/classes/uielements';
import { CommonService } from './common.service';
import { DataService } from './data.service';
import { StoreService } from './store.service';

@Injectable({
  providedIn: 'root'
})
export class UiService {

  constructor(private store: StoreService, private commonservice: CommonService, private dataservice: DataService) { }
  public activePanel = 'Actor'
  public isCollapsed(parameter): boolean {
    return this.activePanel === parameter
  }


  public currentcontentviewtype: 'info'//panorama,express
  public activeview = undefined
  public getIcon(viewtype) {
    //console.log(viewtype);
    if (viewtype === 'actorinfo' || viewtype === 'actor')
      return 'icon-op-member'

    if (viewtype === 'clueinfo' || viewtype === 'clue')
      return 'icon-add-label'

    if (viewtype === 'eventinfo' || viewtype === 'event')
      return 'icon-hot'

    if (viewtype === 'locationinfo' || viewtype === 'location')
      return 'icon-gps'

    if (viewtype === 'groupinfo' || viewtype === 'group')
      return 'icon-go-tree'

    if (viewtype === 'taskinfo' || viewtype === 'task')
      return 'icon-milestone'

    if (viewtype === 'stuffinfo' || viewtype === 'stuff')
      return 'icon-license'
    return ''

  }
  public getShapIcon(shape) {
    if (shape === 'rectangle')
      return 'icon-license'
    if (shape === 'ellipse')
      return 'icon-priority'
    if (shape === '5polygon')
      return 'icon-star-o'
    return ''
  }
  public contentviews:
    {
      title: string,
      viewtype: string,
      data: any
    }[] = []
  public remove(item) {
    let index = this.contentviews.findIndex(v => v.title == item.title)
    if (index > -1) {
      this.contentviews.splice(index, 1)
    }
  }
  public openinfo(name: string, vtype: string, data: any) {

    if (this.contentviews.findIndex(v => v.title == name) == -1) {
      //this.contentviews.forEach(v => v.active = false)
      this.contentviews.push({
        title: name,
        viewtype: vtype,
        data: data
      })

    }
    this.activeview = name
    console.log(this.activeview);
  }

}
